package com.xysoft.admin.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xysoft.admin.service.IOrganizationService;

@Controller
@RequestMapping(value = "/admin/organization.jspx")
public class OrganizationController extends BaseController {
	private IOrganizationService organizationService;
	
	@RequestMapping(params = "index")
	public String get(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.organizationService.get(request, session);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indexOFlevel")
	public String getLevel(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.organizationService.getLevel(request, session);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "add")
	@ResponseBody
	public Map<String,? extends Object> add(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		Map<String,Object> res = this.organizationService.addOrModify(request, session);
		return res;
	}
	
	@RequestMapping(params = "edit")
	@ResponseBody
	public Map<String,? extends Object> modify(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		Map<String,Object> res = this.organizationService.addOrModify(request, session);
		return res;
	}
	
	@RequestMapping(params = "remove")
	@ResponseBody
	public Map<String,? extends Object> del(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		Map<String,Object> res = this.organizationService.del(request, session);
		return res;
	}

	@Autowired
	public void setOrganizationService(IOrganizationService organizationService) {
		this.organizationService = organizationService;
	}
}
